package ThreadDemo1;

import java.security.Signature;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 故我
 * Date: 2023-10-10
 * Time: 17:54
 */
//饿汉模式
class Singleton {
    //先把对象创建出来，设置为static对象，随类
    public static Singleton singleton = new Singleton();

    //通过这个函数获取到这个对象
    public static Singleton GetInstance(){
        return singleton;
    }

    //避免外部创建对象，直接将构造函数私有
    private Singleton(){

    }
}

public class ThreadDemo18 {
    public static void main(String[] args) {
        Singleton s1 = Singleton.GetInstance();
        Singleton s2 = Singleton.GetInstance();

        System.out.println(s1 == s2 ? 1 : 0);
    }
}
